package com.rwcw.admin.config.exception;

import com.rw.engine.permission.exception.PermissionException;
import com.rwcw.admin.vo.ResultVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class PermissionExceptionHandler {
    @ResponseBody
    @ExceptionHandler(PermissionException.class)
    public ResultVO<String> permissionExceptionHandler(PermissionException exception) {
        return new ResultVO<>(500, "Sorry, you do not have permission to access this interface. Required permissions:" + exception.getPermission());
    }
}
